package com.ruoyi.youtian.domain;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysMenu;
import lombok.Data;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Treeselect树结构实体类
 *
 * @author ruoyi
 */
@Data
public class TWorkspaceCategoryTreeSelect implements Serializable
{
    private static final long serialVersionUID = 1L;

    /** 节点ID */
    private Long id;

    /** 节点名称 */
    private String label;

    private String title;

    private String level;

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TWorkspaceCategoryTreeSelect> children;


    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TWorkspaceCategoryTreeSelect> child;

    public TWorkspaceCategoryTreeSelect()
    {

    }

    public TWorkspaceCategoryTreeSelect(SysDept dept)
    {
        this.id = dept.getDeptId();
        this.label = dept.getDeptName();
        this.children = dept.getChildren().stream().map(TWorkspaceCategoryTreeSelect::new).collect(Collectors.toList());
    }

    public TWorkspaceCategoryTreeSelect(SysMenu menu)
    {
        this.id = menu.getMenuId();
        this.label = menu.getMenuName();
        this.children = menu.getChildren().stream().map(TWorkspaceCategoryTreeSelect::new).collect(Collectors.toList());
    }

    public TWorkspaceCategoryTreeSelect(TWorkspaceCategory workspaceCategory)
    {
        this.id = workspaceCategory.getWorkspaceCategoryId();
        this.label = workspaceCategory.getCategoryName();
        this.level = workspaceCategory.getType();
        this.title  = workspaceCategory.getCategoryName();
        this.children = workspaceCategory.getChildren().stream().map(TWorkspaceCategoryTreeSelect::new).collect(Collectors.toList());
    }




}
